package com.yuma.cloud.order.config;

import feign.Logger;
import feign.Retryer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
// 当此服务去调用service-user服务时，使用自定义的负载均衡策略
@LoadBalancerClient(name = "service-user", configuration = CustomLoadBalancerConfiguration.class)
public class RestTemplateConfiguration {

    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    @Bean
    @LoadBalanced  // 添加注解
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
